home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Includes_and_Autodocs_3.5 / include / devices / prtbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  12.1 KB  |  471 lines

  1. #ifndef DEVICES_PRTBASE_H
  2. #define DEVICES_PRTBASE_H
  3. /*
  4. **    $VER: prtbase.h 44.1 (19.10.1999)
  5. **    Includes Release 44.1
  6. **
  7. **    printer driver structure definitions
  8. **
  9. **    (C) Copyright 1987-1999 Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13. #ifndef UTILITY_TAGITEM_H
  14. #include <utility/tagitem.h>
  15. #endif
  16.  
  17. #ifndef  EXEC_DEVICES_H
  18. #include <exec/devices.h>
  19. #endif
  20.  
  21. #ifndef  DEVICES_PARALLEL_H
  22. #include <devices/parallel.h>
  23. #endif
  24.  
  25. #ifndef  DEVICES_SERIAL_H
  26. #include <devices/serial.h>
  27. #endif
  28.  
  29. #ifndef  DEVICES_TIMER_H
  30. #include <devices/timer.h>
  31. #endif
  32.  
  33. #ifndef  DOS_DOSEXTENS_H
  34. #include <dos/dosextens.h>
  35. #endif
  36.  
  37. #ifndef  INTUITION_INTUITION_H
  38. #include <intuition/intuition.h>
  39. #endif
  40.  
  41. /****************************************************************************/
  42.  
  43. struct DeviceData
  44. {
  45.     struct Library    dd_Device;    /* standard library node */
  46.     APTR        dd_Segment;    /* A0 when initialized */
  47.     APTR        dd_ExecBase;    /* A6 for exec */
  48.     APTR        dd_CmdVectors;    /* command table for device commands */
  49.     APTR        dd_CmdBytes;    /* bytes describing which command queue */
  50.     UWORD        dd_NumCommands;    /* the number of commands supported */
  51. };
  52.  
  53. /****************************************************************************/
  54.  
  55. /* IO Flags */
  56. #define IOB_QUEUED    4
  57. #define IOB_CURRENT    5
  58. #define IOB_SERVICING    6
  59. #define IOB_DONE    7
  60.  
  61. #define IOF_QUEUED    (1L<<IOB_QUEUED)
  62. #define IOF_CURRENT    (1L<<IOB_CURRENT)
  63. #define IOF_SERVICING    (1L<<IOB_SERVICING)
  64. #define IOF_DONE    (1L<<IOB_DONE)
  65.  
  66. /* pd_Flags */
  67. #define PB_IOR0        0
  68. #define PB_IOR1        1
  69. #define PB_IOOPENED    2
  70. #define PB_EXPUNGED    7
  71.  
  72. #define PBF_IOR0    (1L<<PB_IOR0)
  73. #define PBF_IOR1    (1L<<PB_IOR1)
  74. #define PBF_IOOPENDED    (1L<<PB_IOOPENED)
  75. #define PBF_EXPUNGED    (1L<<PB_EXPUNGED)
  76.  
  77. /* du_Flags (actually placed in pd_Unit.mp_Node.ln_Pri) */
  78. #define DUB_STOPPED    0
  79.  
  80. #define DUF_STOPPED    (1L<<DUB_STOPPED)
  81.  
  82. #define P_OLDSTKSIZE    0x0800    /* stack size for child task (OBSOLETE) */
  83. #define P_STKSIZE    0x1000    /* stack size for child task */
  84. #define P_BUFSIZE    256    /* size of internal buffers for text i/o */
  85. #define P_SAFESIZE    128    /* safety margin for text output buffer */
  86.  
  87. /****************************************************************************/
  88.  
  89. /*
  90.     "struct PrinterData" was a very bad concept in the old V1.0 days
  91.     because it is both: the device and the unit.
  92.  
  93.     Starting with V44 PrinterData may be duplicated for many Units. But all
  94.     new fields that are specific to the Unit  are now part of the new
  95.     "struct PrinterUnit". Don't touch the private fields!
  96.  
  97.     A note on the function pointers in these data structure definitions:
  98.     unless otherwise specified, all functions expect that their parameters
  99.     are passed on the *stack* rather than in CPU registers. Every parameter
  100.     must be passed a 32 bit long word, i.e. an "UWORD" will use the same
  101.     stack space as an "ULONG".
  102. */
  103.  
  104. struct PrinterData
  105. {
  106.     struct DeviceData pd_Device;
  107.  
  108.     /* PRIVATE & OBSOLETE: the one and only unit */
  109.     struct MsgPort pd_Unit;
  110.  
  111.     /* the printer specific segment */
  112.     BPTR pd_PrinterSegment;
  113.  
  114.     /* the segment printer type */
  115.     UWORD pd_PrinterType;
  116.  
  117.     /* the segment data structure */
  118.     struct PrinterSegment * pd_SegmentData;
  119.  
  120.     /* the raster print buffer */
  121.     UBYTE * pd_PrintBuf;
  122.  
  123.     /* the write function:
  124.      *
  125.      *    LONG PWrite(APTR data,
  126.      *                LONG len);
  127.      */
  128.     LONG (*pd_PWrite)();
  129.  
  130.     /* write function's done:
  131.      *
  132.      *    LONG PBothReady(VOID);
  133.      */
  134.     LONG (*pd_PBothReady)();
  135.  
  136.     /* PRIVATE: port I/O request 0 */
  137.     union {
  138.         struct IOExtPar pd_p0;
  139.         struct IOExtSer pd_s0;
  140.     } pd_ior0;
  141.  
  142.     #define pd_PIOR0 pd_ior0.pd_p0
  143.     #define pd_SIOR0 pd_ior0.pd_s0
  144.  
  145.     /* PRIVATE:  and 1 for double buffering */
  146.     union {
  147.         struct IOExtPar pd_p1;
  148.         struct IOExtSer pd_s1;
  149.     } pd_ior1;
  150.  
  151.     #define pd_PIOR1 pd_ior1.pd_p1
  152.     #define pd_SIOR1 pd_ior1.pd_s1
  153.  
  154.     /* PRIVATE: timer I/O request */
  155.     struct timerequest pd_TIOR;
  156.  
  157.     /* PRIVATE: and message reply port */
  158.     struct MsgPort pd_IORPort;
  159.  
  160.     /* PRIVATE: write task */
  161.     struct Task pd_TC;
  162.  
  163.     /* PRIVATE: and stack space (OBSOLETE) */
  164.     UBYTE pd_OldStk[P_OLDSTKSIZE];
  165.  
  166.     /* PRIVATE: device flags */
  167.     UBYTE pd_Flags;
  168.  
  169.     /* PRIVATE: padding */
  170.     UBYTE pd_pad;
  171.  
  172.     /* the latest preferences */
  173.     struct Preferences pd_Preferences;
  174.  
  175.     /* PRIVATE: wait function switch */
  176.     UBYTE pd_PWaitEnabled;
  177.  
  178.     /**************************************************************
  179.      *
  180.      * New fields for V2.0:
  181.      *
  182.      *************************************************************/
  183.  
  184.     /* PRIVATE: padding */
  185.     UBYTE pd_Flags1;
  186.  
  187.     /* PRIVATE: stack space (OBSOLETE) */
  188.     UBYTE pd_Stk[P_STKSIZE];
  189.  
  190.     /**************************************************************
  191.      *
  192.      *  New fields for V3.5 (V44):
  193.      *
  194.      *************************************************************/
  195.  
  196.     /* PRIVATE: the Unit. pd_Unit is obsolete */
  197.     struct PrinterUnit * pd_PUnit;
  198.  
  199.     /* the read function:
  200.      *
  201.      *    LONG pd_PRead(char * buffer,
  202.      *                  LONG * length,
  203.      *                  struct timeval * tv);
  204.      */
  205.     LONG (*pd_PRead)();
  206.  
  207.     /* call application's error hook:
  208.      *
  209.      *    LONG pd_CallErrorHook(struct Hook * hook,
  210.      *                          struct printerIO * ior,
  211.      *                          struct PrtErrMsg * pem);
  212.      */
  213.     LONG (*pd_CallErrHook)();
  214.  
  215.     /* unit number */
  216.     ULONG pd_UnitNumber;
  217.  
  218.     /* name of loaded driver */
  219.     STRPTR pd_DriverName;
  220.  
  221.     /* the query function:
  222.      *
  223.      *    LONG pd_PQuery(LONG * numofchars);
  224.      */
  225.     LONG (*pd_PQuery)();
  226. };
  227.  
  228. /****************************************************************************/
  229.  
  230. /* Printer Class */
  231. #define PPCB_GFX    0    /* graphics (bit position) */
  232. #define PPCF_GFX    0x1    /* graphics (and/or flag) */
  233. #define PPCB_COLOR    1    /* color (bit position) */
  234. #define PPCF_COLOR    0x2    /* color (and/or flag) */
  235.  
  236. #define PPC_BWALPHA    0x00    /* black&white alphanumerics */
  237. #define PPC_BWGFX    0x01    /* black&white graphics */
  238. #define PPC_COLORALPHA    0x02    /* color alphanumerics */
  239. #define PPC_COLORGFX    0x03    /* color graphics */
  240.  
  241. #define PPCB_EXTENDED    2    /* extended PED structure (V44) */
  242. #define PPCF_EXTENDED    0x4
  243.  
  244. /*
  245.     Some printer drivers (PrinterPS) do not support
  246.     strip printing. An application has to print a page
  247.     using a single print request or through clever use
  248.     of the PRD_DUMPRPORTTAGS printing callback hook.
  249. */
  250. #define PPCB_NOSTRIP    3    /* no strip printing, please */
  251. #define PPCF_NOSTRIP    0x8
  252.  
  253. /* Color Class */
  254. #define    PCC_BW        0x01    /* black&white only */
  255. #define    PCC_YMC        0x02    /* yellow/magenta/cyan only */
  256. #define    PCC_YMC_BW    0x03    /* yellow/magenta/cyan or black&white */
  257. #define    PCC_YMCB    0x04    /* yellow/magenta/cyan/black */
  258. #define    PCC_4COLOR    0x04    /* a flag for YMCB and BGRW */
  259. #define    PCC_ADDITIVE    0x08    /* not ymcb but blue/green/red/white */
  260. #define    PCC_WB        0x09    /* black&white only, 0 == BLACK */
  261. #define    PCC_BGR        0x0A    /* blue/green/red */
  262. #define    PCC_BGR_WB    0x0B    /* blue/green/red or black&white */
  263. #define    PCC_BGRW    0x0C    /* blue/green/red/white */
  264.  
  265. /*
  266.     The picture must be scanned once for each color component, as the
  267.     printer can only define one color at a time.  ie. If 'PCC_YMC' then
  268.     first pass sends all 'Y' info to printer, second pass sends all 'M'
  269.     info, and third pass sends all C info to printer.  The CalComp
  270.     PlotMaster is an example of this type of printer.
  271. */
  272. #define PCC_MULTI_PASS    0x10    /* see explanation above */
  273.  
  274. /****************************************************************************/
  275.  
  276. struct PrinterExtendedData
  277. {
  278.     /* printer name, null terminated */
  279.     char * ped_PrinterName;
  280.  
  281.     /* called after LoadSeg:
  282.      *
  283.      *    LONG ped_Init(struct PrinterData * pd);
  284.      */
  285.     VOID (*ped_Init)();
  286.  
  287.     /* called before UnLoadSeg:
  288.      *
  289.      *    VOID ped_Expunge(VOID);
  290.      */
  291.     VOID (*ped_Expunge)();
  292.  
  293.     /* called at OpenDevice:
  294.      *
  295.      *    LONG ped_Open(struct printerIO * ior);
  296.      */
  297.     LONG (*ped_Open)();
  298.  
  299.     /* called at CloseDevice:
  300.      *
  301.      *    VOID ped_Close(struct printerIO * ior);
  302.      */
  303.     VOID (*ped_Close)();
  304.  
  305.     /* printer class */
  306.     UBYTE ped_PrinterClass;
  307.  
  308.     /* color class */
  309.     UBYTE ped_ColorClass;
  310.  
  311.     /* number of print columns available */
  312.     UBYTE ped_MaxColumns;
  313.  
  314.     /* number of character sets */
  315.     UBYTE ped_NumCharSets;
  316.  
  317.     /* number of 'pins' in print head */
  318.     UWORD ped_NumRows;
  319.  
  320.     /* number of dots max in a raster dump */
  321.     ULONG ped_MaxXDots;
  322.  
  323.     /* number of dots max in a raster dump */
  324.     ULONG ped_MaxYDots;
  325.  
  326.     /* horizontal dot density */
  327.     UWORD ped_XDotsInch;
  328.  
  329.     /* vertical dot density */
  330.     UWORD ped_YDotsInch;
  331.  
  332.     /* printer text command table */
  333.     STRPTR ** ped_Commands;
  334.  
  335.     /* special command handler:
  336.      *
  337.      *    LONG ped_DoSpecial(UWORD * command,
  338.      *                       UBYTE output_buffer[],
  339.      *                       BYTE * current_line_position,
  340.      *                       BYTE * current_line_spacing,
  341.      *                       BYTE * crlf_flag,
  342.      *                       UBYTE params[]);
  343.      */
  344.     LONG (*ped_DoSpecial)();
  345.  
  346.     /* raster render function:
  347.      *
  348.      *    LONG ped_Render(LONG ct,LONG x,LONG y,LONG status);
  349.      */
  350.     LONG (*ped_Render)();
  351.  
  352.     /* good write timeout */
  353.     LONG ped_TimeoutSecs;
  354.  
  355.     /**************************************************************
  356.      *
  357.      * The following only exists if the segment version is >= 33:
  358.      *
  359.      *************************************************************/
  360.  
  361.     /* Conversion strings for the extended font */
  362.     STRPTR * ped_8BitChars;
  363.  
  364.     /* Set if text printed, otherwise 0 */
  365.     LONG ped_PrintMode;
  366.  
  367.     /**************************************************************
  368.      *
  369.      * The following only exists if the segment version is >= 34:
  370.      *
  371.      *************************************************************/
  372.  
  373.     /* ptr to conversion function for all chars:
  374.      *
  375.      *    LONG ped_ConvFunc(UBYTE * buf,
  376.      *                      UBYTE c,
  377.      *                      LONG crlf_flag);
  378.      */
  379.     LONG (*ped_ConvFunc)();
  380.  
  381.     /**************************************************************
  382.      *
  383.      * The following only exists if the segment version is >= 44
  384.      * AND PPCB_EXTENDED is set in ped_PrinterClass:
  385.      *
  386.      *************************************************************/
  387.  
  388.     /* Attributes and features */
  389.     struct TagItem * ped_TagList;
  390.  
  391.     /* driver specific preferences:
  392.      *
  393.      *    LONG ped_DoPreferences(struct printerIO * ior,
  394.      *                           LONG command);
  395.      */
  396.     LONG (*ped_DoPreferences)();
  397.  
  398.     /* custom error handling:
  399.      *
  400.      *    VOID ped_CallErrHook(struct printerIO * ior,
  401.      *                         struct Hook * hook);
  402.      */
  403.     VOID (*ped_CallErrHook)();
  404. };
  405.  
  406. /****************************************************************************/
  407.  
  408. /* The following tags are used to define more printer driver features */
  409.  
  410. #define PRTA_Dummy (TAG_USER + 0x50000)
  411.  
  412. /****************************************************************************/
  413.  
  414. /* V44 features */
  415. #define PRTA_8BitGuns        (PRTA_Dummy + 1) /* LBOOL */
  416. #define PRTA_ConvertSource    (PRTA_Dummy + 2) /* LBOOL */
  417. #define PRTA_FloydDithering    (PRTA_Dummy + 3) /* LBOOL */
  418. #define PRTA_AntiAlias        (PRTA_Dummy + 4) /* LBOOL */
  419. #define PRTA_ColorCorrection    (PRTA_Dummy + 5) /* LBOOL */
  420. #define PRTA_NoIO        (PRTA_Dummy + 6) /* LBOOL */
  421. #define PRTA_NewColor        (PRTA_Dummy + 7) /* LBOOL */
  422. #define PRTA_ColorSize        (PRTA_Dummy + 8) /* LONG */
  423. #define PRTA_NoScaling        (PRTA_Dummy + 9) /* LBOOL */
  424.  
  425. /* User interface */
  426. #define PRTA_DitherNames    (PRTA_Dummy + 20) /* STRPTR * */
  427. #define PRTA_ShadingNames    (PRTA_Dummy + 21) /* STRPTR * */
  428. #define PRTA_ColorCorrect    (PRTA_Dummy + 22) /* LBOOL */
  429. #define PRTA_DensityInfo    (PRTA_Dummy + 23) /* STRPTR * */
  430.  
  431. /* Hardware page borders */
  432. #define PRTA_LeftBorder        (PRTA_Dummy + 30) /* LONG, inches/1000 */
  433. #define PRTA_TopBorder        (PRTA_Dummy + 31) /* LONG, inches/1000 */
  434.  
  435. #define PRTA_MixBWColor        (PRTA_Dummy + 32) /* LBOOL */
  436.  
  437. /* Driver Preferences */
  438. #define PRTA_Preferences    (PRTA_Dummy + 40) /* LBOOL */
  439.  
  440. /****************************************************************************/
  441.  
  442. struct PrinterSegment
  443. {
  444.     BPTR                ps_NextSegment;
  445.     ULONG                ps_runAlert;    /* MOVEQ #0,D0 : RTS */
  446.     UWORD                ps_Version;    /* segment version */
  447.     UWORD                ps_Revision;    /* segment revision */
  448.     struct PrinterExtendedData    ps_PED;        /* printer extended data */
  449. };
  450.  
  451. /****************************************************************************/
  452.  
  453. /*
  454.     Driver specific preferences. This structure is device specific: every
  455.     driver must base its preferences structure on this to allow version
  456.     checking etc.
  457.  
  458.     The application will read/write this structure as an I/O buffer.
  459. */
  460. struct PrtDriverPreferences
  461. {
  462.     UWORD    pdp_Version;                /* PRIVATE! driver specific version */
  463.     UBYTE    pdp_PrinterID[32];            /* PRIVATE! driver specific id */
  464.     char     pdp_PrefName[FILENAME_SIZE-16];
  465.     ULONG    pdp_Length;                /* size of this structure */
  466.  
  467.     /* .. more driver private fields follow .. */
  468. };
  469.  
  470. #endif /* DEVICES_PRTBASE_H */
  471.